<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								玩家 ID ：<input type="text" name="playerId"/>
							</li>

							<!--<li>
								用户名：<input type="text" name="userName"/>
							</li>-->

							<li>
								难度等级：
								<select name="difficultLevel" th:with="type=${@dict.getType('jl_difficult_level')}">
									<option value="">所有</option>
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
								</select>
							</li>

							<li>
								是否在线：
								<select name="isOnline" th:with="type=${@dict.getType('jl_player_online')}">
									<option value="">所有</option>
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
								</select>
							</li>


							<li>
								状态：
								<select name="status" th:with="type=${@dict.getType('sys_normal_disable')}">
									<option value="">所有</option>
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
								</select>
							</li>

							<li class="select-time">
								<label>创建时间： </label>
								<input type="text" class="time-input" id="startTime" readonly="true" placeholder="开始" name="params[startTime]"/>
								<span>-</span>
								<input type="text" class="time-input" id="endTime" readonly="true" placeholder="结束" name="params[endTime]"/>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
				<!--<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="jl:player:add">
					<i class="fa fa-plus"></i> 添加
				</a>-->
				<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="jl:player:edit">
					<i class="fa fa-edit"></i> 修改
				</a>
				<!--<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="jl:player:remove">
					<i class="fa fa-remove"></i> 删除
				</a>
				<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="jl:player:export">
						<i class="fa fa-download"></i> 导出
				 </a>-->
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('jl:player:edit')}]];
        var removeFlag = [[${@permission.hasPermi('jl:player:remove')}]];
        var prefix = ctx + "jl/player";
		// 数据表格相关字段设置
        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                addGoldUrl: prefix + "/addGold",
                modalName: "玩家",
				search: false,
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'playerId', 
					title : '玩家ID',
					visible: true ,
                    sortable: true
				},
				/*{
					field : 'userName',
					title : '用户名',
					sortable: false
				},*/
				{
					field : 'avatar', 
					title : '玩家头像',
					sortable: false,
                    formatter: function(value, item, index) {
						if(value.indexOf('http') == 0) {
                            return '<img width="60px" src=' + value + '>';
						} else {
                            return '<img width="60px" src=' + 'http://' + value + '>';
                        }
                    }
				},
				{
					field : 'nickname',
					title : '昵称',
					sortable: false
				},
				/*{
					field : 'password',
					title : '密码',
					sortable: false
				},*/
				{
					field : 'carryGold', 
					title : '携带金币',
					sortable: true
				},
				{
					field : 'safeGold', 
					title : '保险柜金币',
					sortable: true
				},
				{
					field : 'useupGold', 
					title : '消耗总金币',
					sortable: true
				},
				{
					field : 'gameName',
					title : '当前游戏',
					sortable: false
				},
				/*{
					field : 'currentGameTalbe', 
					title : '当前游戏桌',
					sortable: false
				},*/
				{
					field : 'difficultLevel', 
					title : '难度等级',
					sortable: false,
					formatter: function(value, item, index) {
                        var str = '';
                        if(value == 0) {
                            str = '未设置';
                        } else if(value == 1) {
                            str = '非常容易';
						} else if(value == 2) {
                            str = '容易';
                        } else if(value == 3) {
                            str = '普通';
                        } else if(value == 4) {
                            str = '困难';
                        } else if(value == 5) {
                            str = '非常困难';
                        }
                        return str;
					}
				},
				{
					field : 'vipName',
					title : 'VIP等级',
					sortable: false
				},
				{
					field : 'isOnline', 
					title : '是否在线',
					sortable: false,
                    formatter: function(value, item, index) {
					    var str = '<span class="label label-success">mark</span>';
					    if(value == '0') {
							str = str.replace('mark', '在线');
						} else if(value == '1') {
                            str = str.replace('mark', '下线');
						}
                        return str;
                    }
				},
				/*{
					title: '机器人',
					field: 'isRobot',
					align: "left",
					formatter: function(value, item, index) {
						if(value == 0) {
							return '<span class="label label-success">不是</span>';
						} else if(value == 1) {
							return '<span class="label label-success">是</span>';
						}
					}
				},*/
				{
					field : 'slotType',
					title : '水果类型',
                    formatter: function(value, item, index) {
                        var str = '<span class="label label-success">mark</span>';
                        //0,不控制 1,不出奖 2,九个7 3,全盘蓝牌
                        // 4,全盘红牌 5,全盘黄牌 6,全盘草莓
                        // 7,全盘西瓜 8,全盘铃铛 9,全盘木瓜 10,全盘桔子
                        if(value == 0) {
                            str = str.replace('mark', '不控制');
                        } else if(value == 1) {
                            str = str.replace('mark', '不出奖');
                        } else if(value == 2) {
                            str = str.replace('mark', '九个7');
                        } else if(value == 3) {
                            str = str.replace('mark', '全盘蓝牌');
                        } else if(value == 4) {
                            str = str.replace('mark', '全盘红牌');
                        } else if(value == 5) {
                            str = str.replace('mark', '全盘黄牌');
                        } else if(value == 6) {
                            str = str.replace('mark', '全盘草莓');
                        } else if(value == 7) {
                            str = str.replace('mark', '全盘西瓜');
                        } else if(value == 8) {
                            str = str.replace('mark', '全盘铃铛');
                        } else if(value == 9) {
                            str = str.replace('mark', '全盘木瓜');
                        } else if(value == 10) {
                            str = str.replace('mark', '全盘桔子');
                        }
                        return str;
                    }
				},
				{
					field : 'loginIp', 
					title : 'ip地址',
					sortable: false
				},
				{
					field : 'loginTime',
					title : '登录时间',
					sortable: true,
                    formatter: function(value, item, index) {
                        return value.substring(0, value.length - 3);
                    }
				},
				{
					field : 'createTime',
					title : '创建时间',
					sortable: true,
                    formatter: function(value, item, index) {
                        return value.substring(0, value.length - 3);
                    }
				},
				/*{
					field : 'wxOpenid',
					title : '微信Id',
					sortable: true
				},*/
				{
					field : 'onlineTime', 
					title : '在线时长',
					sortable: true,
                    formatter: function(value, item, index) {
					    if(value == null) {
					        return '0分';
						}
					    return value + '分';
                    }
				},
				{
					visible: editFlag == 'hidden' ? false : true,
					title: '玩家状态',
					align: 'center',
					formatter: function (value, row, index) {
						return statusTools(row);
					}
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.playerId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="addGold(\'' + row.playerId + '\')"><i class="fa fa-edit"></i>加金币</a> ');
                        // actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.playerId + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });

		/* 玩家管理-添加金币 */
        function addGold(playerId) {
            var url = prefix + '/addGold/' + playerId;
            $.modal.open("添加金币", url, '800', '500');
        }

		/* 玩家状态显示 */
        function statusTools(row) {
            if (row.status == 1) {// 停用状态,调用启用状态
                return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.playerId + '\')"></i> ';
            } else {// 启用,调用停用状态
                return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.playerId + '\')"></i> ';
            }
        }

		/* 玩家管理启用 */
        function enable(playerId) {
            $.modal.confirm("确认要启用玩家吗？", function() {
                $.operate.post(prefix + "/changeStatus", { "playerId": playerId, "status": 0 });
            })
        }

		/* 玩家管理-停用 */
        function disable(playerId) {
            $.modal.confirm("确认要禁用玩家吗？", function() {
                $.operate.post(prefix + "/changeStatus", { "playerId": playerId, "status": 1 });
            })
        }


    </script>
</body>
</html>